<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>用户登录</title>
    <link rel="stylesheet" href="layui/css/layui.css">
    <link rel="stylesheet" href="css/admin.css">
    <link rel="stylesheet" href="css/login.css">
</head>

<body>
    <div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">

        <div class="layadmin-user-login-main">
            <div class="layadmin-user-login-box layadmin-user-login-header">
                <h2>欢迎登陆</h2>
                <p>疫苗预约平台</p>
            </div>
            <form id="loginForm">
                <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
                    <div class="layui-form-item">
                        <label class="layadmin-user-login-icon layui-icon layui-icon-username"
                            for="LAY-user-login-username"></label>
                        <input type="text" name="account" id="LAY-user-login-username" lay-verify="required"
                            placeholder="用户名" class="layui-input">
                    </div>
                    <div class="layui-form-item">
                        <label class="layadmin-user-login-icon layui-icon layui-icon-password"
                            for="LAY-user-login-password"></label>
                        <input type="password" name="password" id="LAY-user-login-password" lay-verify="required"
                            placeholder="密码" class="layui-input">
                    </div>
                    <div class="layui-form-item">
                        <input type="button" id="loginBtn" class="layui-btn layui-btn-fluid" lay-submit
                            lay-filter="LAY-user-login-submit" value="登 入" />
                    </div>
                </div>
            </form>
        </div>

        <div class="layui-trans layadmin-user-login-footer">
            <p>© 2022 zing.online 版权所有 <a href="https://beian.miit.gov.cn" target="_blank">粤ICP备20200774xx号</a></p>
        </div>
    </div>

    <script src="layui/layui.js"></script>
    <script>
        layui.use(['layer', 'jquery'], function () {
            var layer = layui.layer;
            var $ = layui.jquery;

            // 绑定登录按钮
            $('#loginBtn').on('click', function () {
                login();
            });
            // 绑定密码框
            $('#LAY-user-login-password').on('keydown', function (e) {
                if (e.keyCode == 13) {
                    login();
                }
            })
            // 登陆
            function login() {
                if ($("#LAY-user-login-username").val() == '' || $("#LAY-user-login-password").val() == '') {
                    layer.msg("请输入用户名或密码");
                    return false;
                }
                var params = $("#loginForm").serialize();
                $.ajax({
                    url: 'user/login',
                    type: 'post',
                    data: params,
                    success: function (data) {
                        if (data.code != 200) {
                            layer.msg(data.data);
                        } else {
                            location.href = data.data;
                        }
                    }
                });
            }
        });
    </script>
</body>

</html>